def generate(n):
    # 初始化杨辉三角
    triangle=[]

    #生成杨辉三角
    for i in range(n):
        row=[1]*(i+1)
        triangle.append(row)
        for j in range(1,i):
            row[j]=triangle[i-1][j-1]+triangle[i-1][j]
    return triangle

#def display(triangle):
    #for row in triangle:
        #print(" ".join(str(num) for num in row).center(len(triangle)*2))

def display(triangle):
    [print(" ".join(str(num) for num in row).center(len(triangle)*2)) for row in triangle]

display(generate(5))